package com.tqfframe.datamanage.config;

import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;

/**
 * @Author: 唐祺峰
 * @Date: 2020/7/14 0014 11:29
 * @Version 1.0
 */
public class UrlFilter implements Filter {

    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
        HttpServletRequest httpRequest = (HttpServletRequest) request;
        String path = httpRequest.getRequestURI();
        //如果包含test则放行，否则定位到其他路由。
//        if (path.indexOf("/test")>-1) {
            chain.doFilter(request, response);
//        } else {
//            path = "/";
//            httpRequest.getRequestDispatcher(path).forward(request, response);
//        }
        return;
    }

    @Override
    public void init(FilterConfig filterConfig) {
        System.out.println("111");
    }

    @Override
    public void destroy() {
        System.out.println("222");
    }
}
